import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import mitt from "mitt"
import useResize from "vite-resize-project"
import Loading from "./components/Loading"
import { MyUse } from './myUse'
import 'virtual:uno.css'


// 全局组件引入
// import Content from "./Layout/Content/index.vue"

export const app = createApp(App)
// 全局组件注册
// app.component("Card", Content)

// 递归组件注册
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './assets/tailwind/index.css'

app.use(ElementPlus)
app.use(useResize)
// app.use(Loading)
MyUse(Loading)

type Filter = {
  format<T>(str: T): string
}

// 声明要扩充@vue/runtime-core包的声明.
// 这里扩充"ComponentCustomProperties"接口, 因为他是vue3中实例的属性的类型.
declare module 'vue' {
  export interface ComponentCustomProperties {
    $env: string
    $filters: Filter
  }
}

type Lod = {
  show: () => void,
  hide: () => void
}

//编写ts loading 声明文件放置报错 和 智能提示
// declare module '@vue/runtime-core' {
declare module 'vue' {
  export interface ComponentCustomProperties {
    $loading: Lod
  }
}


// 注册全局变量
app.config.globalProperties.$env = "env"
app.config.globalProperties.$filters = {
  format<T> (str: T) {
    return `小pp: ${str}`
  }
}

import * as ElementPlusIconsVue from "@element-plus/icons-vue";
for(const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

const Mitt = new mitt()
declare module 'vue' {
  export interface ComponentCustomProperties {
    $bus: typeof Mitt
  }
}
app.config.globalProperties.mittBus = Mitt

app.mount('#app')
